<template>
  <div class="index-page">
    <!-- 顶部导航栏 -->
    <nav class="navbar">
      <div class="nav-container">
        <h1 class="logo">中国城市之旅</h1>
        <ul class="nav-menu">
          <li><router-link to="/" class="nav-link active">首页</router-link></li>
          <li><router-link to="/city" class="nav-link">城市探索</router-link></li>
          <li><router-link to="/about" class="nav-link">关于我们</router-link></li>
        </ul>
      </div>
    </nav>

    <!-- 主要内容 -->
    <main class="main-content">
      <!-- 页面标题区域 -->
      <section class="page-header">
        <div class="header-content">
          <h2 class="page-title">中国城市之旅</h2>
          <p class="page-subtitle">探索中国的美丽城市，发现每个城市的独特魅力与文化底蕴</p>
        </div>
      </section>

      <!-- 热门城市推荐 -->
      <section class="hot-cities-section">
        <div class="section-header">
          <h3 class="section-title">热门城市推荐</h3>
          <p class="section-subtitle">精选中国最具特色的旅游城市</p>
        </div>

        <div class="cities-grid">
          <div class="city-card" v-for="city in hotCities" :key="city.id">
            <div class="city-header" :style="{ background: city.color }">
              <span class="city-icon">{{ city.icon }}</span>
            </div>
            <div class="city-content">
              <h3 class="city-name">{{ city.name }}</h3>
              <p class="city-description">{{ city.description }}</p>
              <div class="city-stats">
                <div class="stat">
                  <span class="stat-icon">👥</span>
                  <span class="stat-text">{{ city.population }}</span>
                </div>
                <div class="stat">
                  <span class="stat-icon">⭐</span>
                  <span class="stat-text">{{ city.rating }}</span>
                </div>
              </div>
              <button class="explore-btn" @click="goToCity(city.name)">探索详情</button>
            </div>
          </div>
        </div>
      </section>

      <!-- 特色美食 -->
      <section class="foods-section">
        <div class="section-header">
          <h3 class="section-title">特色美食</h3>
          <p class="section-subtitle">品尝各地的风味美食</p>
        </div>

        <div class="foods-grid">
          <div class="food-card" v-for="city in hotCities" :key="'food-' + city.id">
            <div class="food-header" :style="{ background: city.color }">
              <span class="food-icon">{{ city.foodIcon }}</span>
            </div>
            <div class="food-content">
              <h3 class="food-name">{{ city.food }}</h3>
              <p class="food-city">{{ city.name }}</p>
              <p class="food-description">{{ city.foodDescription }}</p>
            </div>
          </div>
        </div>
      </section>

      <!-- 统计数据展示 -->
      <section class="stats-section">
        <div class="stats-container">
          <div class="stat-item">
            <span class="stat-number">{{ hotCities.length }}</span>
            <span class="stat-label">热门城市</span>
          </div>
          <div class="stat-item">
            <span class="stat-number">{{ hotCities.length }}</span>
            <span class="stat-label">特色美食</span>
          </div>
          <div class="stat-item">
            <span class="stat-number">50+</span>
            <span class="stat-label">旅游景点</span>
          </div>
          <div class="stat-item">
            <span class="stat-number">1000+</span>
            <span class="stat-label">用户好评</span>
          </div>
        </div>
      </section>
    </main>

    <!-- 尾部信息 - 与图片完全一致 -->
    <footer class="footer">
      <div class="footer-content">
        <p class="copyright" @click="scrollToTop">© 2024 中国城市之旅官方网站</p>
        <div class="footer-links">
          <router-link to="/" class="footer-link" @click="handleFooterClick('首页')">首页</router-link>
          <router-link to="/city" class="footer-link" @click="handleFooterClick('城市探索')">城市探索</router-link>
          <router-link to="/about" class="footer-link" @click="handleFooterClick('关于我们')">关于我们</router-link>
        </div>
      </div>
    </footer>
  </div>
</template>

<script>
export default {
  name: 'IndexView',
  data() {
    return {
      hotCities: [
        {
          id: 1,
          name: '北京',
          icon: '🏯',
          color: 'linear-gradient(135deg, #667eea 0%, #764ba2 100%)',
          description: '千年古都，历史文化名城',
          population: '2188万人',
          rating: '4.8',
          food: '北京烤鸭',
          foodIcon: '🦆',
          foodDescription: '皮脆肉嫩的传统美味'
        },
        {
          id: 2,
          name: '上海',
          icon: '🏙️',
          color: 'linear-gradient(135deg, #f093fb 0%, #f5576c 100%)',
          description: '现代化国际大都市',
          population: '2487万人',
          rating: '4.7',
          food: '小笼包',
          foodIcon: '🥟',
          foodDescription: '汤汁浓郁的经典点心'
        },
        {
          id: 3,
          name: '西安',
          icon: '🏮',
          color: 'linear-gradient(135deg, #4facfe 0%, #00f2fe 100%)',
          description: '古都长安，丝绸之路起点',
          population: '1295万人',
          rating: '4.6',
          food: '羊肉泡馍',
          foodIcon: '🍲',
          foodDescription: '西北风情的特色小吃'
        },
        {
          id: 4,
          name: '成都',
          icon: '🐼',
          color: 'linear-gradient(135deg, #43e97b 0%, #38f9d7 100%)',
          description: '天府之国，美食之都',
          population: '2093万人',
          rating: '4.9',
          food: '火锅',
          foodIcon: '🥘',
          foodDescription: '麻辣鲜香的川味代表'
        },
        {
          id: 5,
          name: '广州',
          icon: '🍜',
          color: 'linear-gradient(135deg, #ff9a9e 0%, #fecfef 100%)',
          description: '美食之都，商贸中心',
          population: '1867万人',
          rating: '4.7',
          food: '肠粉',
          foodIcon: '🍝',
          foodDescription: '滑嫩可口的广式点心'
        },
        {
          id: 6,
          name: '深圳',
          icon: '💻',
          color: 'linear-gradient(135deg, #a1c4fd 0%, #c2e9fb 100%)',
          description: '科技创新之城',
          population: '1756万人',
          rating: '4.8',
          food: '烧鹅',
          foodIcon: '🦢',
          foodDescription: '皮脆肉嫩的粤式烧味'
        },
        {
          id: 7,
          name: '杭州',
          icon: '🏞️',
          color: 'linear-gradient(135deg, #ffecd2 0%, #fcb69f 100%)',
          description: '人间天堂，西湖美景',
          population: '1193万人',
          rating: '4.8',
          food: '西湖醋鱼',
          foodIcon: '🐟',
          foodDescription: '酸甜可口的杭帮菜代表'
        },
        {
          id: 8,
          name: '南京',
          icon: '🏛️',
          color: 'linear-gradient(135deg, #84fab0 0%, #8fd3f4 100%)',
          description: '六朝古都，文化名城',
          population: '931万人',
          rating: '4.6',
          food: '盐水鸭',
          foodIcon: '🦆',
          foodDescription: '鲜嫩可口的金陵名菜'
        },
        {
          id: 9,
          name: '重庆',
          icon: '🌉',
          color: 'linear-gradient(135deg, #d4fc79 0%, #96e6a1 100%)',
          description: '山城雾都，火锅之都',
          population: '3205万人',
          rating: '4.7',
          food: '重庆小面',
          foodIcon: '🍜',
          foodDescription: '麻辣鲜香的重庆特色'
        },
        {
          id: 10,
          name: '苏州',
          icon: '🎋',
          color: 'linear-gradient(135deg, #a6c0fe 0%, #f68084 100%)',
          description: '园林之城，水乡古镇',
          population: '1274万人',
          rating: '4.6',
          food: '松鼠桂鱼',
          foodIcon: '🐠',
          foodDescription: '造型精美的苏帮菜'
        },
        {
          id: 11,
          name: '武汉',
          icon: '🌸',
          color: 'linear-gradient(135deg, #fad0c4 0%, #ffd1ff 100%)',
          description: '江城武汉，九省通衢',
          population: '1232万人',
          rating: '4.5',
          food: '热干面',
          foodIcon: '🍝',
          foodDescription: '香气扑鼻的武汉早餐'
        },
        {
          id: 12,
          name: '厦门',
          icon: '🏝️',
          color: 'linear-gradient(135deg, #ffecd2 0%, #fcb69f 100%)',
          description: '海上花园，温馨之城',
          population: '516万人',
          rating: '4.7',
          food: '沙茶面',
          foodIcon: '🍜',
          foodDescription: '风味独特的闽南小吃'
        }
      ]
    }
  },
  methods: {
    goToCity(cityName) {
      this.$router.push({
        path: '/city',
        query: { search: cityName }
      })
    },

    // 新增底部功能方法
    handleFooterClick(linkName) {
      console.log(`点击了底部链接: ${linkName}`);
      // 可以在这里添加统计代码或其他逻辑
    },

    scrollToTop() {
      window.scrollTo({
        top: 0,
        behavior: 'smooth'
      });
    }
  }
}
</script>

<style scoped>
/* 修复 CSS 变量定义 */
.index-page {
  --primary-color: #2c3e50;
  --secondary-color: #3498db;
  --accent-color: #e74c3c;
  --success-color: #27ae60;
  --text-dark: #2c3e50;
  --text-light: #7f8c8d;
  --border-color: #e0e0e0;
  --background: #f8f9fa;
  --shadow-sm: 0 2px 10px rgba(0,0,0,0.1);
  --shadow-md: 0 5px 20px rgba(0,0,0,0.15);
  --shadow-lg: 0 10px 30px rgba(0,0,0,0.2);
  min-height: 100vh;
  background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
}

/* 导航栏美化 */
.navbar {
  background: linear-gradient(135deg, var(--primary-color) 0%, #34495e 100%);
  padding: 1rem 0;
  box-shadow: var(--shadow-lg);
  position: sticky;
  top: 0;
  z-index: 1000;
  backdrop-filter: blur(10px);
}

.nav-container {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 2rem;
}

.logo {
  color: white;
  font-size: 2rem;
  font-weight: bold;
  text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}

.nav-menu {
  display: flex;
  list-style: none;
  gap: 2rem;
  margin: 0;
  padding: 0;
}

.nav-link {
  color: white;
  text-decoration: none;
  padding: 0.8rem 1.5rem;
  border-radius: 25px;
  transition: all 0.3s ease;
  font-weight: 600;
  position: relative;
  overflow: hidden;
}

.nav-link.active {
  background: rgba(255, 255, 255, 0.2);
  box-shadow: 0 4px 15px rgba(255,255,255,0.2);
}

.nav-link:hover {
  background: rgba(255, 255, 255, 0.15);
  transform: translateY(-2px);
}

/* 页面头部美化 */
.page-header {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  text-align: center;
  padding: 4rem 2rem;
  margin-bottom: 3rem;
  border-radius: 0 0 30px 30px;
  box-shadow: var(--shadow-md);
}

.header-content {
  max-width: 800px;
  margin: 0 auto;
}

.page-title {
  font-size: 3.5rem;
  margin-bottom: 1rem;
  font-weight: bold;
  text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}

.page-subtitle {
  font-size: 1.3rem;
  opacity: 0.9;
  line-height: 1.6;
}

/* 主要内容区域美化 */
.main-content {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 2rem 3rem;
}

/* 区块头部美化 */
.section-header {
  text-align: center;
  margin-bottom: 3rem;
  position: relative;
}

.section-title {
  font-size: 2.8rem;
  color: var(--text-dark);
  margin-bottom: 1rem;
  font-weight: bold;
  position: relative;
  display: inline-block;
}

.section-title::after {
  content: '';
  position: absolute;
  bottom: -10px;
  left: 50%;
  transform: translateX(-50%);
  width: 80px;
  height: 4px;
  background: linear-gradient(135deg, var(--secondary-color) 0%, var(--accent-color) 100%);
  border-radius: 2px;
}

.section-subtitle {
  color: var(--text-light);
  font-size: 1.2rem;
  font-weight: 500;
}

/* 城市网格美化 */
.cities-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 2.5rem;
  margin-bottom: 4rem;
}

.city-card {
  background: white;
  border-radius: 20px;
  overflow: hidden;
  box-shadow: var(--shadow-md);
  transition: all 0.4s ease;
  position: relative;
}

.city-card:hover {
  transform: translateY(-10px) scale(1.02);
  box-shadow: var(--shadow-lg);
}

.city-header {
  height: 140px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.city-header::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.1);
}

.city-icon {
  font-size: 4rem;
  filter: drop-shadow(0 4px 8px rgba(0,0,0,0.3));
  z-index: 1;
}

.city-content {
  padding: 2rem;
  position: relative;
}

.city-name {
  font-size: 1.6rem;
  font-weight: bold;
  color: var(--text-dark);
  margin-bottom: 1rem;
}

.city-description {
  color: var(--text-light);
  margin-bottom: 1.5rem;
  line-height: 1.6;
  font-size: 1rem;
}

.city-stats {
  display: flex;
  gap: 2rem;
  margin-bottom: 1.5rem;
}

.stat {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--text-light);
  font-size: 0.95rem;
}

.stat-icon {
  font-size: 1.2rem;
}

.stat-text {
  font-weight: 600;
}

.explore-btn {
  background: linear-gradient(135deg, var(--secondary-color) 0%, #5dade2 100%);
  color: white;
  border: none;
  padding: 0.8rem 1.5rem;
  border-radius: 25px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  width: 100%;
}

.explore-btn:hover {
  background: linear-gradient(135deg, #2980b9 0%, var(--secondary-color) 100%);
  transform: translateY(-2px);
  box-shadow: 0 5px 15px rgba(52, 152, 219, 0.4);
}

/* 美食网格美化 */
.foods-section {
  margin-bottom: 4rem;
}

.foods-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 2rem;
}

.food-card {
  background: white;
  border-radius: 15px;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: all 0.3s ease;
}

.food-card:hover {
  transform: translateY(-5px);
  box-shadow: var(--shadow-md);
}

.food-header {
  height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.food-icon {
  font-size: 3rem;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.3));
}

.food-content {
  padding: 1.5rem;
}

.food-name {
  font-size: 1.3rem;
  font-weight: bold;
  color: var(--text-dark);
  margin-bottom: 0.5rem;
}

.food-city {
  color: var(--secondary-color);
  font-weight: 600;
  margin-bottom: 0.8rem;
  font-size: 1rem;
}

.food-description {
  color: var(--text-light);
  line-height: 1.5;
  font-size: 0.95rem;
}

/* 统计数据美化 */
.stats-section {
  background: linear-gradient(135deg, #2c3e50 0%, #3498db 100%);
  color: white;
  padding: 4rem 2rem;
  border-radius: 20px;
  margin-top: 3rem;
  box-shadow: var(--shadow-lg);
}

.stats-container {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 3rem;
  text-align: center;
}

.stat-item {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.stat-number {
  font-size: 3.5rem;
  font-weight: bold;
  margin-bottom: 0.5rem;
  text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}

.stat-label {
  font-size: 1.1rem;
  opacity: 0.9;
  font-weight: 500;
}

/* 尾部美化 - 与图片完全一致 */
.footer {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: 2rem 0;
  margin-top: 4rem;
}

.footer-content {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 2rem;
}

.copyright {
  margin: 0;
  font-size: 1rem;
  color: white;
  cursor: pointer;
  transition: opacity 0.3s ease;
}

.copyright:hover {
  opacity: 0.8;
}

.footer-links {
  display: flex;
  gap: 2rem;
}

.footer-link {
  color: white;
  text-decoration: none;
  font-size: 1rem;
  transition: opacity 0.3s ease;
}

.footer-link:hover {
  opacity: 0.8;
}

/* 响应式设计 */
@media (max-width: 768px) {
  .nav-container {
    flex-direction: column;
    gap: 1rem;
  }

  .page-title {
    font-size: 2.5rem;
  }

  .section-title {
    font-size: 2.2rem;
  }

  .cities-grid {
    grid-template-columns: 1fr;
    gap: 2rem;
  }

  .footer-content {
    flex-direction: column;
    gap: 1rem;
    text-align: center;
  }

  .stats-container {
    grid-template-columns: repeat(2, 1fr);
    gap: 2rem;
  }
}

@media (max-width: 480px) {
  .main-content {
    padding: 0 1rem 2rem;
  }

  .page-header {
    padding: 3rem 1rem;
  }

  .city-stats {
    flex-direction: column;
    gap: 1rem;
  }

  .stats-container {
    grid-template-columns: 1fr;
  }
}
</style>